﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LibFriesland_Campina_CRM
{
    public class BizAccount
    {
        #region Thuoc tinh
        public string username { get; set; }
        public string password { get; set; }
        public string id { get; set; }
        public string by_privilege { get; set; }
        public bool disabled { get; set; }
        #endregion

        #region Ham thiet lap
        public BizAccount() { }
        public BizAccount(string pUsername, string pId, string pBy_privilege)
        {
            username = pUsername;
            id = pId;
            by_privilege = pBy_privilege;
        }

        public BizAccount(string pUsername, string pPassword, string pId, string pBy_privilege, bool pDisabled)
        {
            username = pUsername;
            password = pPassword;
            id = pId;
            by_privilege = pBy_privilege;
            disabled = pDisabled;
        }
        #endregion

        #region Phuong thuc
        //Them mot Account moi
        public int addAccount()
        {
            return DalAccount.addAccount(this);
        }

        //Xoa mot Account
        public static int deleteAccount(string pUsername)
        {
            return DalAccount.deleteAccount(pUsername);
        }
        #endregion

        #region Dung cho Webservice
        //Lay danh sach Account
        public static List<BizAccount> getAll()
        {
            return DalAccount.getAll();
        }

        //Cap nhat thong tin Account
        public int updateAccount()
        {
            return DalAccount.updateAccount(this);
        }

        //Dang nhap
        public static BizAccount Login(string pUsername, string pPassword)
        {
            return DalAccount.Login(pUsername, pPassword);
        }

        //Doi mat khau
        public static int changePassword(string pUsername, string pOldPassWord, string pNewPassword)
        {
            return DalAccount.changePassword(pUsername, pOldPassWord, pNewPassword);
        }
        #endregion
    }
}
